package cn.edu.baiyunu.myapplication.ui.screens.transactions.components

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import cn.edu.baiyunu.myapplication.ui.components.Icon

/**
 * 交易操作按钮组，包含编辑和删除按钮
 * 
 * @param onEditClick 编辑按钮点击回调
 * @param onDeleteClick 删除按钮点击回调
 * @param modifier 修饰符
 */
@Composable
fun TransactionActions(
    onEditClick: () -> Unit,
    onDeleteClick: () -> Unit,
    modifier: Modifier = Modifier
) {
    Row(
        modifier = modifier.fillMaxWidth(),
        horizontalArrangement = Arrangement.spacedBy(15.dp)
    ) {
        // 编辑按钮
        ActionButton(
            icon = Icons.Default.Edit,
            text = "编辑",
            tint = Color(0xFF26DE81),
            modifier = Modifier.weight(1f),
            onClick = onEditClick
        )
        
        // 删除按钮
        ActionButton(
            icon = Icons.Default.Delete,
            text = "删除",
            tint = Color(0xFFFF5E62),
            modifier = Modifier.weight(1f),
            onClick = onDeleteClick
        )
    }
}

/**
 * 操作按钮组件
 * 
 * @param icon 按钮图标
 * @param text 按钮文本
 * @param tint 图标和文本颜色
 * @param onClick 点击回调
 * @param modifier 修饰符
 */
@Composable
fun ActionButton(
    icon: ImageVector,
    text: String,
    tint: Color,
    onClick: () -> Unit,
    modifier: Modifier = Modifier
) {
    Column(
        modifier = modifier
            .clip(RoundedCornerShape(15.dp))
            .background(Color.White.copy(alpha = 0.1f))
            .clickable(onClick = onClick)
            .padding(15.dp),
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Icon(
            imageVector = icon,
            contentDescription = text,
            tint = tint
        )
        
        Spacer(modifier = Modifier.height(8.dp))
        
        Text(
            text = text,
            fontSize = 14.sp,
            color = tint
        )
    }
} 